// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Layout.cs" company="ecblog.codeplex.com">
//   emrecoskun.net - ibrahimatay.com
// </copyright>
// <summary>
//   The layout
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace EcBlog.Models
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    
    // using System.ComponentModel.DataAnnotations.Schema;
    using System.Web.Mvc;

    using EcBlog.Properties;

    /// <summary>
    /// The layout
    /// </summary>
    public sealed class Layout 
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Layout"/> class.
        /// </summary>
        public Layout()
        {
            this.Pages = new HashSet<Page>();
        }
         
        /// <summary>
        /// Gets or sets the layout id.
        /// </summary>
        /// <value>
        /// The layout id.
        /// </value>
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public long LayoutId { get; set; }

        /// <summary>
        /// Gets or sets the layout path.
        /// </summary>
        /// <value>
        /// The layout path.
        /// </value>
        [StringLength(100), Display(ResourceType = typeof(ModelLocalization), Name = "LayoutLayoutPath", Order = 2),
            Required(ErrorMessageResourceType = typeof(ModelLocalization), ErrorMessageResourceName = "LayoutLayoutPathRequired")]
        [Remote("CheckDuplicateLayoutPath",
            "Layout",
            "Admin",
            AdditionalFields = "LayoutId",
            ErrorMessageResourceName = "CheckDuplicate", ErrorMessageResourceType = typeof(ModelLocalization))]
        public string LayoutPath { get; set; }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        /// <value>
        /// The name.
        /// </value>
        [Display(ResourceType = typeof(ModelLocalization), Name = "LayoutName", Order = 1), StringLength(100),
            Required(ErrorMessageResourceType = typeof(ModelLocalization), ErrorMessageResourceName = "LayoutNameRequired")]
        [Remote("CheckDuplicateLayoutName",
            "Layout",
            "Admin",
            AdditionalFields = "LayoutId",
            ErrorMessageResourceName = "CheckDuplicate", ErrorMessageResourceType = typeof(ModelLocalization))]
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets the pages.
        /// </summary>
        /// <value>
        /// The pages.
        /// </value>
        [ScaffoldColumn(false)]
        public ICollection<Page> Pages { get; set; }

        /// <summary>
        /// Gets or sets the last modified.
        /// </summary>
        /// <value>
        /// The last modified.
        /// </value>
        [ScaffoldColumn(false)] 
        public DateTime LastModified { get; set; }

        /// <summary>
        /// Gets or sets the last modified user.
        /// </summary>
        /// <value>
        /// The last modified user.
        /// </value>
        [StringLength(50)]
        [ScaffoldColumn(false)] 
        public string LastModifiedUser { get; set; }
    }
}
